#ifndef SERIAL_H
#define SERIAL_H

#include <QWidget>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <qcustomplot.h>

namespace Ui {
class serial;
}

class serial : public QWidget
{
    Q_OBJECT

public:
    explicit serial(QWidget *parent = nullptr);
    ~serial();

    /*描述波形显示设置*/
    double dt = 0.01;//每一点数据的步进值
    double X_max = 500;//每次窗口显示的数据点数

    QVector<double> arrX_left;
    QVector<double> arrY_left;

    QVector<double> arrX_right;
    QVector<double> arrY_right;

    QVector<double> arrX_yaw;
    QVector<double> arrY_yaw;

    QVector<double> arrX_pitch;
    QVector<double> arrY_pitch;

    QSharedPointer<QCPGraphDataContainer> mData;

private slots:
    void on_pushButton_refresh_clicked();//刷新串口

    void on_pushButton_open_clicked();//打开和关闭串口

    void messlot();//串口信息处理函数

    void on_pushButton_clearrecevice_clicked();//清楚串口信息窗口

    void customplot_leftmotor_paint(double data_x, QString data);//左轮速度绘制

    void customplot_rightmotor_paint(double data_x, QString data);//右轮速度绘制

    void customplot_yaw_paint(double data_x, QString data);//偏航角绘制

    void customplot_pitch_paint(double data_x, QString data);//俯仰角绘制

    void on_pushButton_setPID_clicked();

private:
    Ui::serial *ui;
    QSerialPort m_serial;
    QTimer *m_serialTimer;//用于刷新串口的定时器
};

#endif // SERIAL_H
